package com.example.tys.baseapplication.net_tcp.protocol.tcp.KeepAlive;


import com.example.tys.baseapplication.net_tcp.frame.PacketResponse;

import java.util.List;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

/**
 * Created by tys on 2019/5/5.
 */

public class MyDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        byte[] bytes = new byte[in.readableBytes()];
        in.readBytes(bytes);
        String s = new String(bytes);
        System.out.println("decode:" + s);
        PacketResponse packetResponse = new PacketResponse("ANDBZ-090");
        packetResponse.setData(s.getBytes());
        out.add(packetResponse);
    }
}
